package com.iflytek.jobs.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.iflytek.jobs.service.domain.StuLevel;
import com.iflytek.jobs.service.service.IStuLevelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生能力Controller
 * 
 * @author chenhs
 * @date 2023-06-01
 */
@RestController
@RequestMapping("/jobs/stulevel")
public class StuLevelController extends BaseController
{
    @Autowired
    private IStuLevelService stuLevelService;

    /**
     * 查询学生能力列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StuLevel stuLevel)
    {
        startPage();
        List<StuLevel> list = stuLevelService.selectStuLevelList(stuLevel);
        return getDataTable(list);
    }

    /**
     * 导出学生能力列表
     */
    @Log(title = "学生能力", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @PreAuthorize("@ss.notRole('demo')")
    public void export(HttpServletResponse response, StuLevel stuLevel)
    {
        List<StuLevel> list = stuLevelService.selectStuLevelList(stuLevel);
        ExcelUtil<StuLevel> util = new ExcelUtil<StuLevel>(StuLevel.class);
        util.exportExcel(response, list, "学生能力数据");
    }

    /**
     * 获取学生能力详细信息
     */
    @GetMapping(value = "/{psId}")
    public AjaxResult getInfo(@PathVariable("psId") Integer psId)
    {
        return success(stuLevelService.selectStuLevelByPsId(psId));
    }

    /**
     * 新增学生能力
     */
    @Log(title = "学生能力", businessType = BusinessType.INSERT)
    @PostMapping
    @PreAuthorize("@ss.notRole('demo')")
    public AjaxResult add(@RequestBody StuLevel stuLevel)
    {
        return toAjax(stuLevelService.insertStuLevel(stuLevel));
    }

    /**
     * 修改学生能力
     */
    @Log(title = "学生能力", businessType = BusinessType.UPDATE)
    @PutMapping
    @PreAuthorize("@ss.notRole('demo')")
    public AjaxResult edit(@RequestBody StuLevel stuLevel)
    {
        return toAjax(stuLevelService.updateStuLevel(stuLevel));
    }

    /**
     * 删除学生能力
     */
    @Log(title = "学生能力", businessType = BusinessType.DELETE)
	@DeleteMapping("/{psIds}")
    @PreAuthorize("@ss.notRole('demo')")
    public AjaxResult remove(@PathVariable Integer[] psIds)
    {
        return toAjax(stuLevelService.deleteStuLevelByPsIds(psIds));
    }
}
